// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import Resource from 'vue-resource'
import 'element-ui/lib/theme-chalk/index.css'
import { Loading } from 'element-ui' // loading 加载
import { oAuth } from "../util/oAuth.js"
import Vtip from 'vtip'
import 'vtip/lib/index.min.css'

//使用某个组件
Vue.use(ElementUI)
Vue.use(Resource)
Vue.use(Vtip.directive)

//loading实例
let loadingInstance;
router.beforeEach((to, from, next) => {
  loadingInstance = Loading.service({ fullscreen: true });
  document.title = `${to.meta.title}`;
  //登录
  if (oAuth.login()) { 
    //继续执行后面代码
    next()
  }
})

router.afterEach((to, from, next) => {
  loadingInstance.close();
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
